<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 * Description of commoncall
 * 
 * @author Subha Sundar Das (subhasundar.das@gmail.com)
 */
class Commoncall extends CI_Model {

    //put your code here

    function __construct() {
        parent::__construct();
        log_message('debug', 'Model Initialized');
    }
    
    

//-- Random Text (Used for Password Generation//    
    function random_text($lenght=Null) {
        $this->load->helper('string');
        return random_string('numeric', $lenght);
    }
//--Get Visitor IP --/
    function get_ip(){
         //--GET CLIENT IP    
        if (!empty($_SERVER['HTTP_CLIENT_IP'])) {   //check ip from share internet
            $ip = $_SERVER['HTTP_CLIENT_IP'];
        } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {   //to check ip is pass from proxy
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } else {
            $ip = $_SERVER['REMOTE_ADDR'];
        }
        return $ip;
    }
    function check_admin_login() {
        $userdata = $this->session->userdata('sess_admin_user');
        if (!$userdata) {
            redirect('admin/admin_login');
        }
    }

//--Subha (Get Recent News with parameter no of News )--//    
    function get_recent_news($no) {
        if($no){
            $sql= "Select * from News order by id desc limit $no";
            return $this->db->query($sql)->result();
        }       
    }
    
    
}

?>
